@echo off

REM 清除生成的中间文件，只保留.hex文件
SET DIR=%~dp0
echo %DIR%

REM for /f "delims=" %%f in ('dir /s /b Obj') do (echo %%f)
for /f %%f in ('dir /s /b Obj') do (
	for /f %%s in ('dir /s /b %%f') do (	
	if "%%~xs" == ".hex" (echo %%s) else (del %%s /q /f)
	)
)

for /f %%f in ('dir /s /b DebugConfig') do (
	for /f %%s in ('dir /s /b %%f') do ( del %%s /q /f)
)

for /f %%f in ('dir /s /b Output') do (
	for /f %%s in ('dir /s /b %%f') do (	
	if "%%~xs" == ".hex" (echo %%s) else (del %%s /q /f)
	)
)
for /f %%f in ('dir /s /b Listing') do (
	for /f %%s in ('dir /s /b %%f') do (	
		del %%s /q /f
	)
)
for /f %%f in ('dir /s /b Objects') do (
	for /f %%s in ('dir /s /b %%f') do (	
		del %%s /q /f
	)
)
pause